﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MaxLeaf.DB;
using System.Data;

namespace MaxLeaf.DAL.K3
{
    /*
     * Insert into IcPrcPly(FName,FNumber,FPlyType,FPri,FSysTypeID)
Values('test','888','PrcAsm1','0','1')
UPDATE IcPrcPly SET FBillNo=FInterID WHERE FBillNo=''
     */

    /// <summary>
    ///价格政策hdr
    /// </summary>
    public class ICPrcPlyDAL : BaseDAL
    {
        public ICPrcPlyDAL()
            : base()
        {
            strTableName = "ICPrcPly";

            strMapKeyFieldName = "FInterID";
            strDestRealKeyFieldName = "FNumber";
           
            mblnNeedEditKeyValue = false;
            mblnIsIdentity = true;
            blnMapKeyUseOtherKeyFieldsCond = false;

            strFieldNames = "FNumber,FName,FPri,FPlyType,FSysTypeID,FPeriodType,FCycBegTime,FCycEndTime,FWeek,FMonth,FDayPerMonth,FSerialWeekPerMonth,FWeekDayPerMonth,FClassTypeID,FBillNo,FCycDesc,FBItem,FBCust,FBCustCls,FBEmp,FBVIPGrp,FBClientGrp,FBEmpCls,FClientGrp";
        }
        public override void Update(DBAccess dbOrgCon, DBAccess dbDestCon, string strKeyValue)
        {
            KeyValuePair<string, IDataParameter[]> kvp = dbDestCon.CreateCondParam(new Dictionary<string, object>() { { "TableName", strTableName }, { "OrgKeyValue", strKeyValue } });
            string strSql = string.Format("select DestKeyValue from mkeymap where {0}", kvp.Key);

            string strFInterID = dbDestCon.GetValue(strSql, kvp.Value);
            if (strFInterID.Length > 0)
            {
                 
            }
            else
            {
                //key=fnumber+FPlyType
                DataRow drOrgData = dbOrgCon.GetTableDataFirstRow(strTableName, new Dictionary<string, object>() { { strMapKeyFieldName, strKeyValue } });
                dictOtherKeyFieldsCond = new Dictionary<string, object>() { 
                    {"FPlyType",drOrgData["FPlyType"]}
                };
            }
            base.Update(dbOrgCon, dbDestCon, strKeyValue);
        }
    }
}
